<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class CategoryRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 新增
     */
    public function rules()
    {
        return [
            'category_name' => 'required|string|max:8',
        ];
    }

    public function messages()
    {
        return [
            'category_name.required' => '请输入名称',
            'category_name.max' => '名称最多只允许8个字'
        ];
    }

    /**
     * 编辑
     * @return string[]
     */
    public function updateRules()
    {
        return [
            'category_name' => 'required|string|max:8',
        ];
    }

    public function updateMessages()
    {
        return [
            'category_name.required' => '请先输入名称',
            'category_name.max' => '名称最多只允许8个字'
        ];
    }

    /**
     * 排序
     * @return string[]
     */
    public function sortRules()
    {
        return [
            'target_sort' => 'required|integer',
        ];
    }

    public function sortMessages()
    {
        return [
            'target_sort.required' => '请输入当前排序数字',
            'target_sort.integer' => '当前排序数字不符合规则',
        ];
    }
}
